package com.lvan.servicebase.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.function.Predicate;

/**
 * Swagger 文档配置类
 *
 * @author LuoMeng
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket webApiConfig() {
        return new Docket(DocumentationType.OAS_30)
                .groupName("WebApi")
                .apiInfo(webApiInfo())
                .select()
                .paths(Predicate.isEqual(PathSelectors.regex("/error.*")))
                .build();
    }

    private ApiInfo webApiInfo() {
        return new ApiInfoBuilder()
                .title("登录系统API文档")
                .description("登录模块系统测试API文档提供")
                .version("1.0")
                .contact(new Contact("Lvan", "https://hsq.lvan.com", "lvan@foxmail.com"))
                .build();
    }

}
